# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=gnome-builder
pkgname=(gnome-builder gnome-builder-libide-docs)
pkgver=41.1
pkgrel=2
pkgdesc="An IDE for writing GNOME-based software"
url="https://wiki.gnome.org/Apps/Builder"
arch=(x86_64)
license=(GPL3)
depends=(gtksourceview4 devhelp libgit2-glib gjs python-gobject sysprof
         desktop-file-utils ctags libpeas vte3 vala autoconf-archive
         gspell libdazzle template-glib jsonrpc-glib python-sphinx webkit2gtk
         glade python-lxml meson libportal cmark)
makedepends=(llvm gobject-introspection gi-docgen yelp-tools appstream-glib git
             mm-common python-sphinx_rtd_theme clang jedi-language-server
             flatpak-builder)
checkdepends=(xorg-server-xvfb)
_commit=09f585be79f65d8e0a993a8496559afa63d7c0e4  # tags/41.1^0
source=("git+https://gitlab.gnome.org/GNOME/gnome-builder.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/^GNOME_BUILDER_//;s/_/./g;s/-/+/g'
}

prepare() {
  cd $pkgbase
}

build() {
  arch-meson $pkgbase build \
    -D docs=true \
    -D help=true
  meson compile -C build
}

check() {
  dbus-run-session xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

package_gnome-builder() {
  depends+=(libgladeui-2.so)
  optdepends=('gnome-code-assistance: Legacy assistance services'
              'clang: C/C++ code assistance'
              'jedi-language-server: Python code assistance'
              'flatpak-builder: Build Flatpaks')
  groups=(gnome-extra)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"
  _pick libide-docs usr/share/doc/libide
}

package_gnome-builder-libide-docs() {
  pkgdesc+=" (libide API documentation)"
  depends=()
  mv libide-docs/* "$pkgdir"
}

# vim:set sw=2 et:
